package com.yc.blog.springboot.event.demo3;

import java.util.ArrayList;
import java.util.List;

public class SubjectImpl implements Subject {
	
	private List<Observer> observerList = new ArrayList<Observer>();

	@Override
	public void addObserver(Observer observer) {
		observerList.add(observer);
	}

	@Override
	public void removeObserver(Observer observer) {
		observerList.remove(observer);
	}

	@Override
	public void inform() {
		System.out.println("事件触发...");
		for (Observer observer : observerList) {
			observer.todo();
		}
	}

}
